package day12;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;

/**
 * @author Xiao
 * @date 2021/8/3
 */
public class Test02 {
    /**
     * 2. 已知文件中存在包含重复内容的字符串，将文件中的数据去重:
     *     原文：aabbccddeefffffggg
     *     去重后：abcdefg
     */
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("homework\\src\\day12\\file02a.txt");
        LinkedHashSet<Integer> lhs = new LinkedHashSet();
//        HashSet<Integer> lhs = new HashSet();
        int i;
        while ((i = fis.read()) != -1) {
            lhs.add(i);
        }
        fis.close();
        FileOutputStream fos = new FileOutputStream("homework\\src\\day12\\file02a.txt");
        for (Integer integer : lhs) {
            fos.write(integer);
        }
        fos.close();
    }
}
